# Definition for singly-linked list.
class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next
class Solution:
    def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:
        # fast = head
        # slow = head
        # while fast and fast.next:
        #     fast = fast.next.next
        #     slow = slow.next
        # return slow
        count = 0
        arr = []
        while head:
            arr.append(head)
            head = head.next
            count += 1
        mid = count // 2 
        return arr[mid]